package demo4;

interface IA{
    void test();
}
public class Test {
    public void test(){

        System.out.println("test方法被执行了...");
    }

    public static void main(String[] args) {
        new IA(){

            @Override
            public void test() {
                System.out.println("IA的test方法执行了...");
            }
        }.test();
    }

    public static void main2(String[] args) {
        Test test = new Test(){
            @Override
            public void test() {
                System.out.println("重写的test方法被执行了...");
            }
        };
        test.test();
    }
    public static void main1(String[] args) {
        int a = 10;
        new Test(){
            int a = 0;
            @Override
            public void test() {
                System.out.println("重写的test方法被执行了...");
                System.out.println(a);
            }
        }.test();
    }
}
